# -*- coding: utf-8 -*-
# @Time    : 2024/11/23 上午11:17
# @Author  : ly
# @Email   : ly@163.com
# @File    : instruments_panel_page.py
# @Software: PyCharm


from pages.base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select


#仪表盘，添加组件
class InstrumentsPanelPage(BasePage):
    url = '/crm/index.php'

    tjzj_locator = (By.CSS_SELECTOR, '#add')  # 点击添加组件按钮
    name_zj_locator = (By.ID, 'title')  # 组件名
    xzzj_locator = (By.ID, 'widget')  # 选择组件
    bc_locator = (By.XPATH, '//*[@id="dialog-message"]/form/div[4]/div/input[1]')  # 点击保存
    results_locator = (By.XPATH, '/html/body/div[5]/div[3]')
    result_locator = (By.XPATH, '/html/body/div[5]/div[2]')

    def click_tjzj(self):
        self.find_element(self.tjzj_locator).click()  # 点击添加组件按钮

    def input_name_zj(self, zj):
        self.find_element(self.name_zj_locator).send_keys(zj)  # 输入组件名

    def drop_zj(self, xzj):
        zj = Select(self.find_element(self.xzzj_locator))
        zj.select_by_index(xzj)  #

    def click_bc(self):
        self.find_element(self.bc_locator).click()  # 点击保存

    def result(self):
        return self.find_element(self.results_locator).text
